package com.yanqu.road.entity.activity;

import com.yanqu.road.entity.DataObject;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ServerMallBuyRecordMapData extends DataObject {
    private int activityId = 0;

    // key:userId
    private Map<Long, ServerMallBuyRecordUserData> recordDataList = new ConcurrentHashMap<>();

    public ServerMallBuyRecordMapData() {
    }

    public long getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public Map<Long, ServerMallBuyRecordUserData> getRecordDataList() {
        return recordDataList;
    }

    public void setRecordDataList(Map<Long, ServerMallBuyRecordUserData> recordDataList) {
        this.recordDataList = recordDataList;
    }

    public ServerActivityMallDayBuyData getServerMallBuyRecordData(long userId, int mallId, int day){
        ServerMallBuyRecordUserData userData = recordDataList.get(userId);
        if(userData == null){return null;}
        return userData.getServerMallBuyRecordData(mallId, day);
    }

    public void setServerMallBuyRecordData(long userId, int mallId, int day, ServerActivityMallDayBuyData data){
        ServerMallBuyRecordUserData userData = recordDataList.get(userId);
        if(userData == null){
            ServerMallBuyRecordUserData newData = new ServerMallBuyRecordUserData();
            newData.setServerMallBuyRecordData(mallId, day, data);
            recordDataList.put(userId, newData);
        } else {
            userData.setServerMallBuyRecordData(mallId, day, data);
        }
    }
}
